using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using GSN.Rules;

namespace GSNConf.Rules
{
    public partial class AddRuleForm : Form
    {
        private IRule[] rules = null;

        internal IRule selectedRule = null;

        public AddRuleForm()
        {
            InitializeComponent();
        }      

        private void AddRuleForm_Load(object sender, EventArgs e)
        {
            rules = RulesConfigManager.getAllRules();
            foreach (IRule rule in rules)
            {
                cbRules.Items.Add(rule.getName());                
            }

            //cbRules.SelectedIndex = 0;
            btnHelpTooltip.SetToolTip(btnHelp, " ");
        }

        private void btnHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)        
        {
            if (cbRules.SelectedIndex >= 0)
                MessageBox.Show(this, btnHelpTooltip.GetToolTip(btnHelp), btnHelpTooltip.ToolTipTitle,
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            //btnHelpTooltip.Show(btnHelpTooltip.GetToolTip(btnHelp), btnHelp, PointToClient(MousePosition));
        }

        private void cbRules_SelectedIndexChanged(object sender, EventArgs e)
        {
            btnHelpTooltip.ToolTipTitle = rules[cbRules.SelectedIndex].getName();
            btnHelpTooltip.SetToolTip(btnHelp, rules[cbRules.SelectedIndex].getDescription());
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cbRules.SelectedIndex >= 0)
            {
                selectedRule = rules[cbRules.SelectedIndex];
                DialogResult = DialogResult.OK;
                Close();
            }
        }
    }
}